# encoding:utf-8

import string

'''
TAP APPLICATION CONFIGURATION
'''

'''
OVS Commands
'''
vsctl = '/ovs/bin/ovs-vsctl'
appctl = '/ovs/bin/ovs-appctl'
ofctl = '/ovs/bin/ovs-ofctl'

'''
OVS的常用命令行：
# ovs-vsctl add-br <bridge> –set bridge <bridge> datapath_type=pica8 protocol=OpenFlow14
# ovs-vsctl del-br <bridge>
# ovs-vsctl add-port <br0> ge-1/1/<1> vlan_mode=<access> tag=<1> -- set interface ge-1/1/<1> type=pica8
# ovs-vsctl del-port <br0> ge-1/1/<1>
上述命令行主要用于添加/删除网桥和端口
'''

'''
OVS Commands Template
'''
# 获取初始所有物理端口
GET_ALL_PORTS_CMD = string.Template('${vsctl} list-ports ${br_name}')

# 增删改LAG端口
ADD_LAG_PORT_CMD = string.Template('${vsctl} add-port ${br_name} ${lagport_name} vlan-mode=trunk tag=1 -- set interface ${lagport_name} type=pica8_lag options:members=${include_ports} options:lag_type=static')
DEL_LAG_PORT_CMD = string.Template('${vsctl} del-port ${br_name} ${lagport_name}')
MOD_LAG_PORT_CMD = string.Template('${vsctl} set Interface ${lagport_name} options:members=${include_ports}')

# 设置关联控制器
SET_CONTROLLER_CMD = string.Template('${vsctl} set-controller ${br_name} tcp:${controller_ip}:${controller_port}')

# 增删改查流表项信息
GET_FLOW_ENTRY_BY_ID_CMD = string.Template('${ofctl} dump-flows ${br_name} flow_id=${flow_id}')
GET_FLOW_ENTRY_BY_MATCH_CMD = string.Template('${ofctl} dump-flows ${br_name} ${match_fields}')
GET_FLOW_TABLE_CMD = string.Template('${ofctl} dump-flows ${br_name}')
ADD_FLOW_ENTRY_CMD = string.Template('${ofctl} add-flow ${br_name} ${match_fields},actions=${actions}')
MOD_FLOW_ENTRY_CMD = string.Template('${ofctl} mod-flows ${br_name} ${match_fields},actions=${actions}')
DEL_FLOW_ENTRY_CMD = string.Template('${ofctl} del-flows ${br_name} flow_id=${flow_id}')

# 增删改查组表信息
GET_GROUP_TABLES_CMD = string.Template('${ofctl} dump-groups ${br_name}')
ADD_GROUP_TABLE_CMD = string.Template('${ofctl} add-group ${br_name} group_id=${group_id},type=${group_type},bucket=${actions}')
MOD_GROUP_TABLE_CMD = string.Template('${ofctl} mod-group ${br_name} group_id=${group_id},type=${group_type},bucket=${actions}')
DEL_GROUP_TABLE_CMD = string.Template('${ofctl} del-groups ${br_name} group_id=${group_id}')

'''
OVS Bridge
'''
bridge_name = 'mainbr'
traffic_capacity = 10
traffic_interval = 5

'''
SSH Configuration
'''
local = False
hostsite = '192.168.1.121'
username = 'admin'
password = 'pica8'
keyfile = 'static/host_key.pub'